package gov.dhs.cis.soa.data;

import gov.dhs.cis.soa.Constants;
import gov.dhs.cis.soa.Utils;
import gov.dhs.cis.soa.Constants.EntityType;

import java.sql.Timestamp;


public class Processes extends AbstractSOAData {
	public static final String STEREO_TYPE = "Process";

	public int id;
	public String name;
	public transient String descText;
	public String stereotype;
	public String wipt;
	public String release;
	public String maturity;
	public String implMethod;
	public transient String steps;
	public String integrationCfg;
	public String IST;		//added RSingh - 09/27/2010
	public transient String designAspects;
	public transient String busProcName;
	public transient int volumetrics;
	public Description desc;
	public transient Timestamp createdDt = new Timestamp(System.currentTimeMillis());

	@Override
	public String toString() {
		return "Processes [id=" + id + ", name=" + name + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Processes other = (Processes) obj;
		if (id == other.id && name.equalsIgnoreCase(other.name))
			return true;
		return false;
	}
	
	public void createDescription() {
		StringBuffer txt = new StringBuffer();
		if(Utils.isEmpty(descText))
			descText = "";
			txt.append(Constants.NL+"Description = " + descText);
		if(Utils.isEmpty(steps))
			steps = "";
		txt.append(Constants.NL+"Steps = " + steps);
		if(Utils.isEmpty(designAspects))
			designAspects = "";
		txt.append(Constants.NL+"Design Aspects = " + designAspects);
		if(Utils.isEmpty(busProcName))
			busProcName = "";
		txt.append(Constants.NL+"Business Process = " + busProcName);
		//if(volumetrics > 0)
			txt.append(Constants.NL+"Volumetrics = " + volumetrics);
		
		desc = Utils.prepareDescObj(txt.toString(), EntityType.PROC);
	}
	
/*	public List<Actor> getRefByActor() {
		return refByActors;
	}
*/
/*	
	public void addReferedSerivice(Service servObj) {
		if(servObj == null)
			return;
		Service foundO = Utils.findServiceById(servObj.id, refByServices);
		if(foundO == null) {
			if(refByServices == null)
				refByServices = new ArrayList<Service>();
			refByServices.add(servObj);
		}
	}
	
	public void addReferedInterface(Interface ifaceObj) {
		if(ifaceObj == null)
			return;
		Interface foundO = Utils.findInterfaceById(ifaceObj.id, refByInterfaces);
		if(foundO == null) {
			if(refByInterfaces == null)
				refByInterfaces = new ArrayList<Interface>();
			refByInterfaces.add(ifaceObj);
		}
	}

	public void addReferedActor(Actor actrObj) {
		if(actrObj == null)
			return;
		Actor foundO = Utils.findActorById(actrObj.id, refByActors);
		if(foundO == null) {
			if(refByActors == null)
				refByActors = new ArrayList<Actor>();
			refByActors.add(actrObj);
		}
	}

	public void addReferedUseCase(UseCase useCase) {
		if(useCase == null)
			return;
		UseCase foundO = Utils.findUseCaseByNumber(useCase.unumber, refByUseCases);
		if(foundO == null) {
			if(refByUseCases == null)
				refByUseCases = new ArrayList<UseCase>();
			refByUseCases.add(useCase);
		}
	}
*/
	
//	public static String getUMLId(int entityId) {
//		return EntityType.PROC + "_" + entityId;
//	}
	@Override
	public long getId() {
		return id;
	}
	@Override
	public String getHashableId() {
		return name;
	}
	
	@Override
	public EntityType getUMLType() {
		return EntityType.PROC;
	}
}
